package com.adjaisd.scarecrow.testJava;

import com.adjaisd.scarecrow.dto.QuotaInfo;
import com.adjaisd.scarecrow.entity.Alarm;
import com.adjaisd.scarecrow.repo.TimeSeriesRepository;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
public class testInflux {

    @Autowired
    TimeSeriesRepository timeSeriesRepository;

    @Test
    public void testAdd() {
        QuotaInfo quotaInfo = new QuotaInfo();
        quotaInfo.setDeviceId("123456");
        quotaInfo.setQuotaId("1");
        quotaInfo.setName("温度");
        quotaInfo.setReference("0-10");
        quotaInfo.setUnit("摄氏度");
        quotaInfo.setAlarm("1");
        quotaInfo.setValue(12D);
        timeSeriesRepository.add(quotaInfo);
    }

    @Test
    void testQuery() {
        String s = "from(bucket:\"device\") |> range(start: 0)";
        List<Alarm> query = timeSeriesRepository.query(s, Alarm.class);
        System.out.println(query);
    }

}

